﻿<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>MonArch Mobile 7.51</title>
<link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAA6dURLEWS94vGJVGylytZ_RRwyLBVg7QVZHo8M39j9_L1n2sr2BRHwzXHq5z4oV4y_Ie_LB7Q2vZ1nw" type="text/javascript"></script>
    <script src="/js/jquery-1.6.1.min.js" type="text/javascript"></script>
 <script type="text/javascript">
     var map = null;
     var geocoder = null;

     if (navigator.geolocation)
         map = null;
     else
         alert("HTML5 Geolocation 미지원 브라우저");

     function initialize() {
         if (GBrowserIsCompatible()) {
             map = new GMap2(document.getElementById("map_canvas"));
             geocoder = new GClientGeocoder();
             map.enableGoogleBar();  // 지도에 검색 input 창 나오게함
             map.setUIToDefault();    // 줌인기능. 지도,위성들 나오게함 
         }
     }

     function showAddress(address) {
         if (geocoder) {
            geocoder.getLatLng( address,showAddressCallBack);
         }
        navigator.geolocation.getCurrentPosition(geolocationCallBack);
     }
     function showAddressCallBack(point) {
         if (!point) {
             alert(address + " not found");
         } else {
             map.setCenter(point, 13);
             var marker = new GMarker(point);
             map.addOverlay(marker);
             marker.openInfoWindowHtml(address);
         }
     }

     function init() {
         var q1 = getUrlVars()["q1"];
         if (q1 == undefined) {
             q1 = "서울시 금천구 가산동 60-19";
         } else {
            q1 = decodeURI(q1);
         }

         GUnload();
         initialize();
         showAddress(q1);
         return true;
     }

     function getUrlVars() {
         var vars = [], hash;
         var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
         for (var i = 0; i < hashes.length; i++) {
             hash = hashes[i].split('=');
             vars.push(hash[0]);
             vars[hash[0]] = hash[1];
         }
         return vars;
     }

     function geolocationCallBack(pos)
      {
        var Mypoint = new GLatLng(pos.coords.latitude, pos.coords.longitude);
        var Mymarker = new GMarker(Mypoint);
        map.addOverlay(Mymarker);
        Mymarker.openInfoWindowHtml("나의위치");
      }
      
      function errorCallback(error)
      {
        switch(error.code) 
        {
        case error.TIMEOUT:
            alert ("시간초과");
            break;
        case error.POSITION_UNAVAILABLE:
            alert ("위치 정보 이용 불가능");
            break;
        case error.PERMISSION_DENIED:
            alert ("권한 거부");
            break;
        case error.UNKNOWN_ERROR:
            alert ("알 수 없는 에러");
            break;
        }
      }
      

    
    </script>
</head>
<body onload="init()">
  <div id="map_canvas" style="width:100%;height:100%"></div>
</body>
</html>


